package com.lin;

import java.util.HashMap;

public class Solution03 {
    public int fourSumCount(int[] A, int[] B, int[] C, int[] D) {
        int ans = 0;
        HashMap<Integer,Integer> map = new HashMap<>();
        for (int i : A) {
            for (int i1 : B) {
                map.put(i+i1,map.getOrDefault(i+i1,0)+1);
            }
        }
        for (int i : C) {
            for (int i1 : D) {
                if(map.containsKey(-i-i1)){
                    ans += map.get(i+i1);
                }
            }
        }
        return ans;
    }
}
